extends "../ankeleiqi-2/ankeleiqi-2.gd"


func _extInit():
	._extInit()
	if isInManual():
		addSkill(sk2t1[1], sk2t1[0])
		addSkill(sk2t2[1], sk2t2[0])
	elif sk2 != 0:
		doChoiceSkill2()
	lv = 3             #等级的设置

var sk2t1 = ["极子光矛·1", "<固化><先手>每12秒对当前目标发射具有穿透性的光束，并持续轰击5秒，每半秒对被轰击的敌人造成[雷击*1]的可暴击技能伤害"]
var sk2t2 = ["极子光矛·2", "<固化><先手>每12秒对当前目标发射具有穿透性的光束，并持续轰击5秒，每半秒对被轰击的敌人造成[雷击*0.6]的技能伤害并附带3层<灼烧>"]

func doChoiceSkill2():
	var sk = get("sk2t%d"%sk2)
	addSkill(sk[1], sk[0])

func _onBattleStart():
	._onBattleStart()
	skFlag = 10

func _onBattleEnd():
	._onBattleEnd()
	skFlag = 10

var skFlag = 0
func _upS():
	._upS()
	skFlag += 1
	if skFlag >= 12 and sk2 > 0:
		skFlag = 0
		var index = 0
		var tcell = aiCha.cell
		var tpos = aiCha.global_position
		var addiFactor = 1
		if lv == 4 and sk3 == 2:
			addiFactor = 1.3

		for num in range(32):
			index += 1
			createJiGuang(tpos, self)
			var dmg = att.mgiAtk * 1
			if sk2 == 2:
				dmg = att.mgiAtk * 0.6
			
			#计算帧数换算伤害
			dmg *= 0.3	

			if index >= 3:
				index = 0
				var lineChas = utils.lineChas(cell, tcell, 10)
				for cha in utils.lineChas(cell, tcell, 10):
					if cha.team != team:
						azurHurtChara(cha, dmg, sys.HurtType.WEAPON, sys.AtkType.SKILL, "极子光矛", sk2 == 1, addiFactor)
						if sk2 == 2 and not cha.isDeath:
							castBuff(cha, buff.b_zhuoShao.new(1))
						if lv == 4 and sk3 == 1 and sys.rndPer(30):
							#激光折射
							var enemy = null
							var chas = []
							for i in getAllChas(1):
								if not lineChas.has(i):
									chas.append(i)
							if not chas.empty():
								enemy = sys.rndListItem(chas)
							if enemy == null:
								continue
							createJiGuang(enemy.global_position, cha)
							for cha2 in utils.lineChas(cha.cell, enemy.cell, 10):
								if cha2.team != team:
									azurHurtChara(cha2, dmg, sys.HurtType.WEAPON, sys.AtkType.SKILL, "极子光矛", sk2 == 1, addiFactor)
									if sk2 == 2 and not cha2.isDeath:
										castBuff(cha2, buff.b_zhuoShao.new(1))
			yield(reTimer(0.15),"timeout")
			if not sys.main.isAiStart:return

func createJiGuang(toPos, cha):
	var eff:Eff = cha.newEff("sk_jiGuan", cha.global_position)
	eff.sprLookAt(toPos)
	eff.scale *= 2
	eff.normalSpr.position = Vector2(0, -25)
	eff.spr.scale.x = 1.5		